<?php
defined( '_VALID_MOS' ) or die('<script>window.location.href="http://www.kinifurniture.com";</script>');

$adm_functions->is_admin_login();
$section='Edit Site Configuration';
$adm_menu='
<table width="100%" class="menubar" cellpadding="0" cellspacing="0" border="0">
	<tr>
		<td class="menudottedline" width="40%">
			<div class="pathway"><img src="assets/admin/'.$SITE_LOGO_ADMIN.'"/></div>	</td>
		<td class="menudottedline" align="right">
			<table cellpadding="0" cellspacing="0" border="0" id="toolbar">
				<tr valign="middle" align="center">
					<td>&nbsp;</td>
					<td>
					<a class="toolbar" href="javascript:kliksubmit();">
						<img src="show_files/save.png"  alt="Save" name="save" title="Save" align="middle" border="0" />				<br />Save</a>
					</td>
					<td>&nbsp;</td>
					<td>
						<a class="toolbar" href="admin.php">
						<img src="show_files/cancel.png"  alt="Cancel" name="cancel" title="Cancel" align="middle" border="0" />				<br />Cancel</a>
					</td>
				</tr>
			</table>
		</td>
	</tr>
</table>
<br />
';

	$qryedit="select * from general_setting where id=1";
	$selectedit=$dbh->query($qryedit);

	while($sqlRowedit=mysql_fetch_object($selectedit))
	{
		$val_site_title=$sqlRowedit->site_title;
		$val_password=$sqlRowedit->password;
		$val_logo_front=$sqlRowedit->logo_front;
		if ($val_logo_front=='') $val_logo_front='logo1.jpg';
		$val_view_logo_front='<img src="assets/admin/'.$val_logo_front.'" /><br/>';
		if ($val_logo_front=='' || $val_logo_front=='logo1.jpg')
			$image_front='<input type="file" name="inp_upl_img_front"/>';
		else
			$image_front='<input class="inputbox" type="checkbox" name="inp_del_img_front" value="Y" /> Delete this image <font color="green">('.$val_logo_front.')</font>';
		$val_logo_admin=$sqlRowedit->logo_admin;
		if ($val_logo_admin=='') $val_logo_admin='logo2.jpg';
		$val_view_logo_admin='<img src="assets/admin/'.$val_logo_admin.'" /><br/>';
		if ($val_logo_admin=='' || $val_logo_admin=='logo2.jpg')
			$image_admin='<input type="file" name="inp_upl_img_admin"/>';
		else
			$image_admin='<input class="inputbox" type="checkbox" name="inp_del_img_admin" value="Y" /> Delete this image <font color="green">('.$val_logo_admin.')</font>';
	}

if($inp_site_title)
{
	if ($inp_del_img_admin=='Y')
	{
		$dbh->query("update general_setting set 
			logo_admin=''
			where id=1");
		@unlink("assets/admin/".$val_logo_admin);
	}
	if ($inp_del_img_front=='Y')
	{
		$dbh->query("update general_setting set 
			logo_front=''
			where id=1");
		@unlink("assets/admin/".$val_logo_front);
	}
	if($_FILES['inp_upl_img_admin']['name'])
	{
		$img_name1=basename($_FILES['inp_upl_img_admin']['name']);
		$uploaddir1 = 'assets/admin/';
		$uploadfile1 = $uploaddir1 . basename($_FILES['inp_upl_img_admin']['name']);
		move_uploaded_file($_FILES['inp_upl_img_admin']['tmp_name'], $uploadfile1);
		$dbh->query("update general_setting set 
			logo_admin='$img_name1'
			where id=1");
	}
	if($_FILES['inp_upl_img_front']['name'])
	{
		$img_name2=basename($_FILES['inp_upl_img_front']['name']);
		$uploaddir2 = 'assets/admin/';
		$uploadfile2 = $uploaddir2 . basename($_FILES['inp_upl_img_front']['name']);
		move_uploaded_file($_FILES['inp_upl_img_front']['tmp_name'], $uploadfile2);
		$dbh->query("update general_setting set 
			logo_front='$img_name2'
			where id=1");
	}

		$dbh->query("update general_setting set 
			site_title='$inp_site_title',
			password='$inp_password'
			where id=1");
		echo '<script>window.location.href="admin.php?show=configuration";</script>';
//	}
}
?>